(function(){
	var _script={};
	var _exeQueue = [];
	var _deps = {};
	var  currentlyAddingScript = null;
	var  interactiveScript = null;
	var loadJs = function(urls,callback){
		var head = document.getElementsByTagName('head')[0];
		urls.forEach(function(o){

			loadCore(head,o);
		});
	}
	function loadCore(head,url){
		var script = document.createElement('script');
		script.type = "text/javascript";
		script.src = url;
		script.setAttribute('abUrlKey', getAbsoluteUrl(url));
		script.onload = onScriptLoad;
		currentlyAddingScript = script;
		head.appendChild(script);
		currentlyAddingScript = null;
	}
	function getAbsoluteUrl(url){ 
		var a = document.createElement('A'); 
		a.href = url; // 设置相对路径给Image, 此时会发送出请求 
		url = a.href; // 此时相对路径已经变成绝对路径 
		return url; 
	} 

    function getInteractiveScript() {
        if (interactiveScript && interactiveScript.readyState === 'interactive') {
            return interactiveScript;
        }
        var scripts = document.getElementsByTagName('script');
        eachReverse(scripts, function (script) {
            if (script.readyState === 'interactive') {
                return (interactiveScript = script);
            }
        });
        return interactiveScript;
    }
    function eachReverse(ary, func) {
        if (ary) {
            var i;
            for (i = ary.length - 1; i > -1; i -= 1) {
                if (ary[i] && func(ary[i], i, ary)) {
                    break;
                }
            }
        }
    }
	function define(urls,fn){
		var script = currentlyAddingScript||getInteractiveScript();
		var s1 = document.currentScript.src;
		if(Array.isArray(urls)){
			var args = [];
			// urls.forEach(function(o){
			// 	var abUrlKey = getAbsoluteUrl(o);
			// 	var ret = _script[abUrlKey];
			// 	if(!ret){
			// 		if(typeof fn == 'function'){
			// 			ret = fn();
			// 		}else{
			// 			ret = fn;
			// 		}
			// 	}
			// 	args.push(ret);
			// });
			
		}else if(!fn){
			fn = urls;

		}
	}
	function onScriptLoad(e){
		var node = e.currentTarget || e.srcElement;
		var abUrlKey = node.getAttribute('abUrlKey');

	}
	window.require = loadJs;
	window.define = define;
})();